//
//  XMSurgeryDetailTableViewCell.m
//  XiaoMiao
//
//  Created by Jim huang on 2018/4/24.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "XMSurgeryDetailTableViewCell.h"

@interface XMSurgeryDetailTableViewCell ()<UITextViewDelegate>

@end

@implementation XMSurgeryDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
    
}

-(void)setUI{
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.partLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.timeLabel.mas_bottom).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.surgetyTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.partLabel.mas_bottom).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);

    }];
    
    [self.materialsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.surgetyTypeLabel.mas_bottom).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.materialsLabel.mas_bottom).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.width.equalTo(@40);
    }];
    
    [self.remarkTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.remarkLabel).offset(-8);
        make.left.equalTo(self.remarkLabel.mas_right);
        make.right.equalTo(self.contentView).offset(-15);
        make.height.equalTo(@40);
    }];
    
    
    [self.remarkPlaceHolder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.remarkTextView).offset(8);
        make.left.equalTo(self.remarkTextView).offset(5);
    }];
   
}


#pragma mark - textviewDelegate
-(void)textViewDidChange:(UITextView *)textView{
    self.remarkPlaceHolder.hidden = textView.text.length;
    if (self.textChangeBlock) {
        self.textChangeBlock(textView.text);
    }
}


#pragma mark ----gettin&setting----

//时间节点
-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.text = @"术前";
        _timeLabel.textColor = HEX_RGB(0x6d6d6d);
        _timeLabel.font = kFont(14);
        _timeLabel.numberOfLines = 1;
        [self.contentView addSubview:_timeLabel];
    }
    return _timeLabel;
}

//部位
-(UILabel *)partLabel{
    if (!_partLabel) {
        _partLabel = [[UILabel alloc]init];
        _partLabel.text = @"部位:";
        _partLabel.textColor = HEX_RGB(0x6d6d6d);
        _partLabel.font = kFont(14);
        _partLabel.numberOfLines = 1;
        [self.contentView addSubview:_partLabel];
    }
    return _partLabel;
}

//手术类型
-(UILabel *)surgetyTypeLabel{
    if (!_surgetyTypeLabel) {
        _surgetyTypeLabel = [[UILabel alloc]init];
        _surgetyTypeLabel.text = @"项目位置:";
        _surgetyTypeLabel.textColor = HEX_RGB(0x6d6d6d);
        _surgetyTypeLabel.font = kFont(14);
        _surgetyTypeLabel.numberOfLines = 1;
        [self.contentView addSubview:_surgetyTypeLabel];
    }
    return _surgetyTypeLabel;
}

//材料
-(UILabel *)materialsLabel{
    if (!_materialsLabel) {
        _materialsLabel = [[UILabel alloc]init];
        _materialsLabel.text = @"材料:";
        _materialsLabel.textColor = HEX_RGB(0x6d6d6d);
        _materialsLabel.font = kFont(14);
        _materialsLabel.numberOfLines = 1;
        [self.contentView addSubview:_materialsLabel];
    }
    return _materialsLabel;
}

//备注
-(UILabel *)remarkLabel{
    if (!_remarkLabel) {
        _remarkLabel = [[UILabel alloc]init];
        _remarkLabel.text = @"备注:";
        _remarkLabel.textColor = HEX_RGB(0x6d6d6d);
        _remarkLabel.font = kFont(14);
        [self.contentView addSubview:_remarkLabel];
    }
    return _remarkLabel;
}


-(UILabel *)remarkPlaceHolder{
    if (!_remarkPlaceHolder) {
        _remarkPlaceHolder = [[UILabel alloc]init];
        _remarkPlaceHolder.font = kFont(14);
        _remarkPlaceHolder.text = @"可输入备注信息";
        _remarkPlaceHolder.textColor = kTextGrayColor;
        [self.contentView addSubview:_remarkPlaceHolder];

    }
    return _remarkPlaceHolder;
}
//备注输入框
-(UITextView *)remarkTextView{
    if (!_remarkTextView) {
        _remarkTextView = [[UITextView alloc]init];
        _remarkTextView.font = kFont(14);
        _remarkTextView.delegate = self;
        _remarkTextView.textColor =HEX_RGB(0x6d6d6d);
        [self.contentView addSubview:_remarkTextView];
    }
    return _remarkTextView;
}


-(void)setShowRemark:(BOOL)showRemark{
    _showRemark = showRemark;
    self.remarkLabel.hidden = !showRemark;
    self.remarkTextView.hidden = !showRemark;
    self.remarkPlaceHolder.hidden = !showRemark;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
